using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Utility;
using Entities;
using BUS;
public partial class Admin_NhanVienEdit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            load_data();
        }
    }
    private void load_data()
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            tbNhanVien  nhanvien = tbNhanVienBUS .GetId (id);
            if (nhanvien != null)
            {
                txt_MaNV .Text = nhanvien.IdNhanVien .ToString();
                txt_TaiKhoan.Text = nhanvien.TaiKhoan.ToString();
                txt_MatKhau.Text = nhanvien.MatKhau.ToString();
                txt_TenNV.Text = nhanvien.TenNhanVien.ToString();
                txt_DiaChi.Text = nhanvien.DiaChi.ToString();
                txt_DienThoai.Text = nhanvien.DienThoai.ToString();
            }
        }
        catch
        {
            Response.Redirect("~/Admin/NhanVienList.aspx");
        }
    }
    protected void btn_Update_Click(object sender, EventArgs e)
    {
        try
        {
            tbNhanVien nhanVien = tbNhanVienBUS.GetId(int.Parse(txt_MaNV.Text));
            nhanVien.IdNhanVien = int.Parse (txt_MaNV.Text);
            nhanVien.TaiKhoan = txt_TaiKhoan.Text;
            nhanVien.MatKhau = txt_MatKhau.Text;
            nhanVien.TenNhanVien = txt_TenNV.Text;
            nhanVien.DiaChi = txt_DiaChi.Text;
            nhanVien.DienThoai = txt_DienThoai.Text;
            tbNhanVienBUS.Update_NhanVien(nhanVien);
            Response.Redirect("~/Admin/SanPhamList.aspx");
        }
        catch 
        {
            Response.Redirect("~/Admin/SanPhamList.aspx");
        }
    }
}
